package Code.Objects.Characters.Player.Weapons.Ranged.AmmoBased.RapidFire;

import org.jrabbit.base.input.MouseHandler;
import org.jrabbit.standard.game.graphics.skins.animation.AnimatedSkin;

import Code.Objects.Characters.Player.Player;
import Code.Objects.Characters.Player.Weapons.Ranged.AmmoBased.PlayerAmmoBasedWeapon;

public class PlayerRapidFireWeapon extends PlayerAmmoBasedWeapon
{
	protected float shotInterval;
	protected float shotTimer;

	public PlayerRapidFireWeapon(AnimatedSkin skin, Player p) 
	{
		super(skin, p);
	}

	public void activeUpdate(int delta)
	{
		shotTimer -= delta;
		if(MouseHandler.isButtonDown(0))
		{
			while(shotTimer < 0)
			{
				shotTimer += shotInterval;
				attemptToFire();
			}
		}
		else if(shotTimer < 0)
		{
			shotTimer = 0;
		}
	}
}
